/**********************************************************************\

 Copyright 2012 Diggory Blake

 This file is part of klip-engine

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

\**********************************************************************/
#pragma once

#include <deque>
#include <stdint.h>

class kImageCache;
class kImage;
class kGraphics;

#include "kbase.h"
#include "kmath.h"
#include "keimageoptions.h"

class kImageCache : public kBase {
private:
	kGraphics* _graphics;
	uint32_t _cacheSize;
	std::deque<kImage*> _images;

public:
	inline kImageCache(kGraphics* graphics, uint32_t cacheSize = 16) {
		_graphics = graphics;
		_cacheSize = cacheSize;
	}
	~kImageCache();

	kImage* get(std::function<bool (const kVec2i&, keImageOptions)> isCompatible);
	void release(kImage* image);
	void clear();
};
